%h3.page-title
  Projects (#{@projects.total_count})
.light
  You can browse public projects in read-only mode until signed in.
%hr
.clearfix
  .pull-left
    = form_tag public_projects_path, method: :get, class: 'form-inline form-tiny' do |f|
      .form-group
        = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input input-mn-300", id: "projects_search"
      .form-group
        = submit_tag 'Search', class: "btn btn-primary wide"

  .pull-right
    .dropdown.inline
      %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
        %span.light sort:
        - if @sort.present?
          = @sort.humanize
        - else
          Name
        %b.caret
      %ul.dropdown-menu
        %li
          = link_to public_projects_path(sort: nil) do
            Name
          = link_to public_projects_path(sort: 'newest') do
            Newest
          = link_to public_projects_path(sort: 'oldest') do
            Oldest
          = link_to public_projects_path(sort: 'recently_updated') do
            Recently updated
          = link_to public_projects_path(sort: 'last_updated') do
            Last updated

%hr
.public-projects
  %ul.bordered-list.top-list
    - @projects.each do |project|
      %li
        %h4
          = link_to project_path(project) do
            = project.name_with_namespace
          - if project.internal?
            %small.access-icon
              = internal_icon
              Internal
          .pull-right
            %pre.public-clone git clone #{project.http_url_to_repo}

        - if project.description.present?
          %p
            = project.description

        .repo-info
          - unless project.empty_repo?
            = link_to pluralize(project.repository.round_commit_count, 'commit'), project_commits_path(project, project.default_branch)
            &middot;
            = link_to pluralize(project.repository.branch_names.count, 'branch'), project_branches_path(project)
            &middot;
            = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project)
          - else
            %i.icon-warning-sign
            Empty repository
    - unless @projects.present?
      .nothing-here-block No public projects

  = paginate @projects, theme: "gitlab"
